package com.scribbles.admin.dao;


import java.io.Serializable;
import java.util.List;

import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;

import org.springframework.stereotype.Repository;

import com.scribbles.common.dao.AbstractDAO;
import com.scribbles.common.entity.LookupType;

@Repository
public class LookupTypeDAO extends AbstractDAO<LookupType, Serializable>{
	public LookupTypeDAO(){
		super(LookupType.class);
	}
	
	/**
	 * @return
	 */
	public List<Object> findAllUsingCriteriaAPI() {		
		CriteriaBuilder criteriaBuilder = em.getCriteriaBuilder();
		CriteriaQuery<Object> criteriaQuery = criteriaBuilder.createQuery();
		Root<LookupType> from = criteriaQuery.from(LookupType.class);
		
		CriteriaQuery<Object> select = criteriaQuery.select(from);
		TypedQuery<Object> typedQuery = em.createQuery(select);
		List<Object> resultList = typedQuery.getResultList();
		
		return resultList;
	}
}
